<%--
 *  File:    UserAuthorityCondition.jsp
 *  @Author: Kent Zhong
 *  Date:    2002/05/31
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.OvalLabel" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom-tag.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.UserAuthorityCondition"); 
   
  String strModuleName = "UPM";
  String privilegeCode = "Z0102,L401";
  
  HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  
  cat.debug("The userinfo is :"+userinfo);
  cat.info("enter my page");
  
  
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>

<html>
<head>
<title>UserAuthorityCondition</title>
<PageFlow:CheckPageFlow pageName="userauthoritycondition"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script language="JavaScript">

    function page_summary(actionvalue,orderbyname)
    {
      var editform = summaryPrepare(userauthorityconditionform,actionvalue,orderbyname);
      editform.action = "UserAuthorityCondition.jsp?<%= OvalTools.randomURL() %>";
      editform.target = "_self";
      isRunning = true;
      editform.submit();  
    }
    
    function page_add()
    {
        if(isEmpty(document.userauthorityconditionform.privilegecode.value))
        {
            alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_PrivilegeCode",false)) %>");
            return ;
        }
        if(isEmpty(document.userauthorityconditionform.conditionid.value))
        {
            alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Condition",false)) %>");
            return ;
        }
        document.userauthorityconditionform.actionname.value = "add";
        document.userauthorityconditionform.target="_self";
        isRunning = true;
        document.userauthorityconditionform.submit();
    }
 <%--[SCRIPT]     function page_edit()  [SCRIPT]--%>
 <%--[SCRIPT]     {  [SCRIPT]--%>
 <%--[SCRIPT]         document.userauthorityconditionform.actionname.value = "save";  [SCRIPT]--%>
 <%--[SCRIPT]         document.userauthorityconditionform.target="_self";  [SCRIPT]--%>
 <%--[SCRIPT]         document.userauthorityconditionform.submit();  [SCRIPT]--%>
 <%--[SCRIPT]     }  [SCRIPT]--%>
    function page_delete()
    {
        with(document.userauthorityconditionform)
        {
            if(typeof(detailids)=="undefined" || detailids==null )
                return;
            if(detailids.length==null)
            {
                if( !detailids.checked)
                {
                    alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
                    return;
                }
            }
            else
            {
                var bFlag=false;
                for(var i=0;i<detailids.length;i++)
                {
                    if(detailids[i].checked)
                    {
                        bFlag=true;
                        break;
                    }
                }
                if(!bFlag)
                {
                    alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
                    return;
                }
            }
        }
        
        var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
        if(!flag)
          return;
        document.userauthorityconditionform.actionname.value = "delete";
        document.userauthorityconditionform.target="_self";
        isRunning = true;
        document.userauthorityconditionform.submit();
    }
    
    function page_selectpriv()
    {
        var usid=document.userauthorityconditionform.userid.value;
        var strUrl="PrivListDetailJumpSingle.jsp?<%= OvalTools.randomURL() %>&userid="+usid;
        var strLocation="height=210, width=600,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no"
        window.open(strUrl, "newwindow",strLocation );
    }
    
    function pop_selectpriv(privid,privcode,privname)
    {
        document.userauthorityconditionform.privilegeid.value=privid;
        document.userauthorityconditionform.privilegecode.value=privcode;
        document.userauthorityconditionform.privilegename.value=privname;
        var remotewin=window.open("", "newwindow","" );
        if(remotewin!=null)
            remotewin.close();
    }
<%--[SCRIPT]    [SCRIPT]--%>
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="userauthorityconditionform" method="post" action="../../Dispatcher"  target="_parent">
    <input type="hidden" name="pagename" value="userauthoritycondition">
    <input type="hidden" name="actionname">   
    <input type="hidden" name="languagecode" value="<%=JspHelper.filterNull( session.getAttribute("languagecode") )%>">   
<%
    Integer IntUserId=(Integer)pageContext.getAttribute("userid");
    if(IntUserId==null)
        IntUserId=new Integer(-1);
    
 %>
 <input  type=hidden name=userid value="<%=JspHelper.filterNull(IntUserId.intValue())%>">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <%--form name="form1" method="post" action="UserGroupSummary.htm"--%>
    <tr> 
      <td valign="top"> 
        <table width="100%" border="0" cellspacing="0">
          <tr> 
            <td class="summary_top" ></td>
          </tr>
          <tr> 
            <td valign="middle" align="left" height="10"><img src="../../images/<%= strLanguageCode %>/quote.gif" width="16" height="11"> 
               <%=label.getLabelName("L_PrivilegeCondition")+label.getLabelName("L_Colon")%></td>  
          </tr>
        </table>
        <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="0">
          <tr class="deepblue-left" >
            <td class="title_center" width="22" >&nbsp;</td>
            <td class="title_center" width="30%" ><%=label.getLabelName("L_PrivilegeCode")%></td>
            <td class="title_center" width="30%" ><%=label.getLabelName("L_PrivilegeName")%></td>
            <td class="title_center" ><%=label.getLabelName("L_Condition")%></td>
          </tr>
          <%
            Vector conditionsummary=(Vector)pageContext.getAttribute("userauthorityconditionsummary");
            if( conditionsummary==null)
                conditionsummary=new Vector();
            Vector allconditions=(Vector)pageContext.getAttribute("allconditions");
            if(allconditions==null)
                allconditions=new Vector();
            cat.debug("conditionsummary is :"+conditionsummary);
            cat.debug("allconditions is :"+allconditions);
            
            String strClassType="none";
            int i=0;
          %>
          <logic:iterate id="conditionsummaryitem" collection="<%= conditionsummary %>">
          <%
            if(i%2 == 1)
            {
              	strClassType = "td-listrom";
            }else{                    
              	strClassType = "none";
            }
            i++;
          %>
          <tr class="<%=JspHelper.filterNull(strClassType)%>">
            <td >
              <input type="checkbox" name="detailids" id="userauthoritycondition<%=JspHelper.filterNull(i)%>" value="<oval:write name="conditionsummaryitem" property="userauthoritycondition"/>" class="normalradio">
            </td>
            <td >&nbsp;<oval:write name="conditionsummaryitem" property="privilegecode"/></td>
            <td >&nbsp;<oval:write name="conditionsummaryitem" property="privilegename"/></td>
            <td >&nbsp;<oval:write name="conditionsummaryitem" property="conditiondesc"/></td>
          </tr>
          </logic:iterate>
          <%
            if(i%2 == 1)
            {
              	strClassType = "td-listrom";
            }else{                    
              	strClassType = "none";
            }
            i++;
          %>
          <input type=hidden name=privilegeid >
          
          <tr class="<%=JspHelper.filterNull(strClassType)%>">
            <td >&nbsp; </td>
            <td >
              <input type="text" name="privilegecode">&nbsp;<span class="red">*</span>
              <a onclick="page_selectpriv();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a> </td>
            <td >
              <input type="text" name="privilegename" readonly style="border:0" class="<%=JspHelper.filterNull(strClassType)%>">
            </td>
            <td >
              <oval:select property="conditionid" optionsName="allconditions"   optionValueKey="conditionid" optionInnerTextKey="conditiondesc" defaultValue="------" defaultValueCost=""/>
              <span class="red">*</span>
            </td>
          </tr>
          <tr> 
            <td colspan="4"> 
              <table width="100%" cellspacing="0" border="0">
               <%@ include file="/inc/SummaryAction.inc" %>
              </table>
            </td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td class="summary_top" ></td>
          </tr>
          <tr> 
            <td class="td_center">
                <a onclick="page_add();"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
                <%--a href="javascript:page_edit();"><a onclick=""><custom:button type="1" label="L_Edit" imgsrc="Modify.gif" border="0" style="width:60"/></a></a--%>
                <a onclick="page_delete();"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
                <a onclick="self.location.href='../../common/Blank.jsp?<%= OvalTools.randomURL() %>';"><custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/></a>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  
</table>
</form>
</body>
</html>


